/**
 * 
 */
package org.dbwebx.gwt.mvp.view;

import com.google.gwt.user.client.ui.Composite;
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;

/**
 * @author Izzet_Mustafayev
 * 
 */
public class TreeManageView extends Composite implements ITreeManageView {

	private TreePanel treePanel = new TreePanel();
	private TreeNode rootNode = new TreeNode("Stub root node");

	public TreeManageView() {
		treePanel.setRootNode(rootNode);
		treePanel.setHeight("100%");
		initWidget(treePanel);
	}

	public void setRootNode(final TreeNode rootNode) {
		this.rootNode = rootNode;
	}

	public void setRootNode(final String rootNodeName) {
		rootNode.setText(rootNodeName);
	}

	public void addItem(TreeNode node) {
		rootNode.appendChild(node);
	}

	public TreeNode getNode(int index) {
		TreeNode resultNode = null;
		if (index == 0) {
			resultNode = rootNode;
		}
		if (index > 0) {
			treePanel.getNodeById(String.valueOf(index));
		}
		return resultNode;
	}

	public int getItemCount() {
		return 0;
	}

}
